package init

import (
	"api_server/basic/config"
	__ "api_server/basic/proto"
	"api_server/utils"
	"github.com/google/uuid"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
	"log"
)

func init() {
	GetGroup()
}

func GetGroup() {

	client, _ := utils.NewConsulClient("14.103.143.229:8500")

	consul := utils.Consul{
		ID:      uuid.NewString(),
		Name:    "consul3",
		Tags:    []string{"consul", "consul3"},
		Port:    8087,
		Address: "127.0.0.1",
	}

	client.ConsulRegister(consul)

	conn, err := grpc.NewClient("127.0.0.1:50051", grpc.WithTransportCredentials(insecure.NewCredentials()))
	if err != nil {
		log.Fatalf("did not connect: %v", err)
	}
	config.UserClient = __.NewUserClient(conn)
}
